<script lang="ts" setup>
import { ref, computed } from 'vue'
import { FormInstance } from 'element-plus'

const props = defineProps<{
  type: string
}>()
interface Form {
  phone: string
  orderId: string
  [prop: string]: any
}
const form = defineModel<Form>({ required: true })

const formRef = ref<FormInstance | null>(null)
const emits = defineEmits(['search'])

const IdLabel = computed(() => {
  if (props.type == 'charge') {
    return '充值订单号'
  } else if (props.type == 'timerent') {
    return '行程编号'
  } else {
    return '订单号'
  }
})

const search = () => {
  emits('search', form)
}
const reset = () => {
  formRef.value?.resetFields()
}
</script>

<template>
  <el-form :model="form" inline ref="formRef">
    <el-form-item prop="phone" label="手机号">
      <el-input v-model="form.phone" placeholder="请输入" />
    </el-form-item>
    <el-form-item prop="orderId" :label="IdLabel">
      <el-input v-model="form.orderId" placeholder="请输入" />
    </el-form-item>
    <slot name="select" />
    <el-form-item>
      <el-button type="primary" @click="search">查询</el-button>
      <el-button @click="reset" plain>重置</el-button>
    </el-form-item>
  </el-form>
</template>

<style scoped></style>
